package com.aids_malaria.http.response;

import android.arch.persistence.room.Embedded;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;

import com.aids_malaria.http.request.AdverseReaction;
import com.aids_malaria.http.request.TokenDrug;
import com.aids_malaria.util.GsonUtil;
import com.litesuits.orm.db.annotation.NotNull;
import com.litesuits.orm.db.enums.AssignType;

import java.io.Serializable;

@Entity(tableName = "drugallergyInfoPack",primaryKeys = {"identity_code","record_seq"})
public class DrugallergyInfoPack implements Serializable {

//    @PrimaryKey(AssignType.BY_MYSELF)
    @NonNull
    private String identity_code;
    private int record_seq;
    private String  allergy_info; // 过敏史
    private String allergy_drug; // 过敏药史
    @Embedded
    private AdverseReaction adverse_reactions; // 不良反应
    private String adverse_reactions_json; //
    private String investor; // 调查者
    private String create_time; // 创建时间
    private String update_time; // 更新时间
    private String invest_time; // 调查时间

    private int busy_type;  // 1：新增  2：update

    private boolean createOrUpdate;

    public boolean isCreateOrUpdate() {
        return createOrUpdate;
    }

    public void setCreateOrUpdate(boolean createOrUpdate) {
        this.createOrUpdate = createOrUpdate;
    }

    public static DrugallergyInfoPack copyFromNoPack(DrugallergyInfo drugallergyInfo){
        DrugallergyInfoPack drugallergyInfoPack = new DrugallergyInfoPack();
        drugallergyInfoPack.setIdentity_code(drugallergyInfo.getIdentity_code());
        drugallergyInfoPack.setRecord_seq(drugallergyInfo.getRecord_seq());
        drugallergyInfoPack.setAllergy_info(drugallergyInfo.getAllergy_info());
        drugallergyInfoPack.setAllergy_drug(drugallergyInfo.getAllergy_drug());
        drugallergyInfoPack.setInvestor(drugallergyInfo.getInvestor());
        drugallergyInfoPack.setCreate_time(drugallergyInfo.getCreate_time());
        drugallergyInfoPack.setUpdate_time(drugallergyInfo.getUpdate_time());
        drugallergyInfoPack.setInvest_time(drugallergyInfo.getInvest_time());
        String adverse_reactions = drugallergyInfo.getAdverse_reactions();
        drugallergyInfoPack.setAdverse_reactions_json(adverse_reactions);
        AdverseReaction adverseReaction = GsonUtil.gsonToBean(adverse_reactions, AdverseReaction.class);
        drugallergyInfoPack.setAdverse_reactions(adverseReaction);

        return drugallergyInfoPack;
    }

    public String getAdverse_reactions_json() {
        return adverse_reactions_json;
    }

    public void setAdverse_reactions_json(String adverse_reactions_json) {
        this.adverse_reactions_json = adverse_reactions_json;
    }

    public String getIdentity_code() {
        return identity_code;
    }

    public void setIdentity_code(String identity_code) {
        this.identity_code = identity_code;
    }

    public int getRecord_seq() {
        return record_seq;
    }

    public void setRecord_seq(int record_seq) {
        this.record_seq = record_seq;
    }

    public String getAllergy_info() {
        return allergy_info;
    }

    public void setAllergy_info(String allergy_info) {
        this.allergy_info = allergy_info;
    }

    public String getAllergy_drug() {
        return allergy_drug;
    }

    public void setAllergy_drug(String allergy_drug) {
        this.allergy_drug = allergy_drug;
    }

    public AdverseReaction getAdverse_reactions() {
        return adverse_reactions;
    }

    public void setAdverse_reactions(AdverseReaction adverse_reactions) {
        this.adverse_reactions = adverse_reactions;
    }

    public String getInvestor() {
        return investor;
    }

    public void setInvestor(String investor) {
        this.investor = investor;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }

    public String getInvest_time() {
        return invest_time;
    }

    public void setInvest_time(String invest_time) {
        this.invest_time = invest_time;
    }

    public int getBusy_type() {
        return busy_type;
    }

    public void setBusy_type(int busy_type) {
        this.busy_type = busy_type;
    }

    @Override
    public String toString() {
        return "DrugallergyInfoPack{" +
                "identity_code='" + identity_code + '\'' +
                ", record_seq=" + record_seq +
                ", allergy_info='" + allergy_info + '\'' +
                ", allergy_drug='" + allergy_drug + '\'' +
                ", adverse_reactions=" + adverse_reactions +
                ", investor='" + investor + '\'' +
                ", create_time='" + create_time + '\'' +
                ", update_time='" + update_time + '\'' +
                ", invest_time='" + invest_time + '\'' +
                '}';
    }
}
